import { createStyles, Theme, withStyles } from "@material-ui/core/styles";
import { WithStyles } from "@material-ui/core/styles/withStyles";
import * as React from "react";
import { Card, Col, Row } from "antd";
import { RouteComponentProps } from "react-router";
import { newsData } from "../health-information/InformationContent";
import { useEffect } from "react";

const styles = (theme: Theme) =>
  createStyles<"root">({
    root: {
      marginTop: 30
    }
  });

interface Iprops
  extends WithStyles<typeof styles>,
    RouteComponentProps<newsData> {}

/**
 * 描述：
 *  资讯查看
 * @author sunshixiong
 * @date 2019/3/26-17:10
 */
const ViewsCheck = (props: Iprops) => {
  useEffect(() => {
    if (!props.location.state) {
      props.history.goBack();
    }
  }, []);
  const data: newsData = props.location.state||{};
  return (
    <Row type={"flex"} justify={"center"} className={props.classes.root}>
      <Col span={12} style={{ marginRight: 10 }}>
        <Card hoverable={true}>
          <div
              dangerouslySetInnerHTML={{ __html: data.content ? data.content : "" }}
          />
          <div>{data.createTime}</div>
        </Card>
      </Col>
    </Row>
  );
};

export default withStyles(styles)(ViewsCheck);
